package com.steven.ourcontest.chat.api

import com.steven.ourcontest.chat.bean.ApplyFriendRes
import com.steven.ourcontest.chat.bean.ChatHistoryRes
import com.steven.ourcontest.chat.bean.ChatOnLineRes
import com.steven.ourcontest.chat.bean.FriendList
import com.steven.ourcontest.chat.bean.UserDetailRes
import com.steven.ourcontest.net.BaseResponse
import com.steven.ourcontest.net.EmptyResponse
import io.reactivex.Observable
import retrofit2.http.*

interface ChatApiService {

    @FormUrlEncoded
    @POST("/chat/message/send")
    fun sendMessageTo(
        @Field("receiveUser") receiveUser: Long,
        @Field("message") message: String
    ): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/chat/message/queryAll")
    fun query2UserAllMessage(
        @Field("friendId") friendId: Long,
        @Field("lastCreateTime") lastCreateTime: Long
    ): Observable<BaseResponse<ChatOnLineRes>>

    @FormUrlEncoded
    @POST("/chat/message/updateStatus")
    fun updateMessageStatus(
        @Field("sendUser") sendUser: Long
    ): Observable<BaseResponse<EmptyResponse>>

    @POST("/friend/query")
    fun queryFriends(): Observable<BaseResponse<FriendList>>

    @FormUrlEncoded
    @POST("/friend/apply")
    fun sendApplyToFriend(
        @Field("toUser") toUser: Long
    ): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/friend/updateApplication")
    fun updateApplication(
        @Field("applicantUser") applicantUser: Long,
        @Field("agree") agree: Boolean
    ): Observable<BaseResponse<EmptyResponse>>

    @POST("/friend/queryApplicationToSelf")
    fun queryApplicationToSelf(): Observable<BaseResponse<ApplyFriendRes>>

    @POST("/friend/querySelfApplication")
    fun querySelfApplication(): Observable<BaseResponse<ApplyFriendRes>>

    @POST("/friend/ApplicantReadStatus/updateToUser")
    fun updateApplicantReadStatus(): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/friend/delete")
    fun deleteFriend(@Field("friendId") friendId: Long): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/user/detail")
    fun queryUserDetail(@Field("friendId") friendId: Long): Observable<BaseResponse<UserDetailRes>>

    @POST("/friend/chatHistory")
    fun queryChatFriends(): Observable<BaseResponse<ChatHistoryRes>>

    @FormUrlEncoded
    @POST("/ban/add")
    fun addUserBan(@Field("userId") userId: Long): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/ban/delete")
    fun deleteUserBan(@Field("userId") userId: Long): Observable<BaseResponse<EmptyResponse>>
}